<template>
  <div>
      <div>
            <label>用户:</label>
            <Input  style="width: 200px" v-model="username" />
      </div>
      <div>
          <label>密码:</label>
          <Input  type="password" style="width: 200px" v-model="password"/>
      </div>
      <div>
          <Button type="primary" style="width: 230px" v-on:click="login">登录</Button>
      </div>
       <div>
       <router-link to="/register">注册</router-link>
       </div>
  </div>
</template>

<script>
import service from '@/service/index'
    export default{
        name:'login',
        data:()=>{
            return{
            username: '',
            password: ''
            }
        },
        methods:{
            login(){
                console.log(this.username,this.password)
                service.post('/login',{
                    body: JSON.stringify({
                        userName:this.username,
                        passWord:this.password
                    })
                })
                .then((res)=>{
                    console.log(res)
                    if(res.retcode=-1){
                        window.location.href='/'
                    }
                })
            }
        }
    }
</script>

<style lang="scss" scoped>

</style>

